package me.abel.auditing.config;

import org.springframework.data.domain.AuditorAware;

import java.util.Optional;

/**
 * 此方式适用于Auditor类型为指定类型，并且审计字段作为数据表中单一字段的情形
 */
//@Component
public class SpringAuditorAware implements AuditorAware<String> {

    @Override
    public Optional<String> getCurrentAuditor() {
//        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//
//        if (authentication == null || !authentication.isAuthenticated()) {
//            return Optional.empty();
//        }
//
//        return authentication.getPrincipal();
        return Optional.ofNullable("user");
    }

}